package com.wu.server.dao;

import com.wu.server.entity.Type;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

/**
 * @author Wugs
 * @version 1.0
 * @date 2021/2/28 15:06
 */
@Repository
public interface GoodsTypeRepository extends CrudRepository<Type, Integer> {
    /**
     * // TODO: 2021/3/4 根基type_num
     * 获取前10条占比高的数据
     * @return
     */
    @Query(value="select *  from jd_shop.type order by jd_shop.type.type_sum desc limit 10;",nativeQuery=true)
    Iterable<Type> getPrinceOrder();
    /**
     * // TODO: 2021/3/4 根基type_sales
     * 获取前10条占比高的数据
     * @return
     */
    @Query(value="select *  from jd_shop.type order by jd_shop.type.type_sales desc limit 10;",nativeQuery=true)
    Iterable<Type> getSalesOrder();

    /**
     * 获取自营京东商品数量
     * @return
     */
    @Query(value="select count(*)  from jd_shop.goods where shop_name like '%自营%'",nativeQuery = true)
    int getSelf();

    /**
     * 获取所有商品数量
     * @return
     */
    @Query(value="select count(*)  from jd_shop.goods ;",nativeQuery = true)
    int getSummary();

    /**
     * 获取最大销量的商品标签
     * @return
     */
    @Query(value="select *  from jd_shop.type order by type_sales desc limit 1;",nativeQuery=true)
    Type getMaxSales();
}
